import { BodySetup } from "utils/creep/CreepSetup";
import { ActionBase, ActionBaseOfCreep } from "../ActionBase";
import { EActionCode } from "framework/FSM/Action/ActionCode";
/**
 * 升级Action
 */
export class ActionDrop  extends ActionBaseOfCreep<IActionCMD<"drop">>
{
    protected _execute(action: IActionCMD<"drop">): EActionCode 
    {
        const p = action.arg.pos;
        const creep = action.arg.entity;
        if(creep.store.getUsedCapacity()==0)
        {
            return  EActionCode.OK;
        }
        if(p.distance(creep.pos)>0)
        {
            const code = creep.mymoveTo({pos:p,range:0},{});
            if(ERR_NO_PATH == code|| code == ERR_NOT_FOUND as any)
            {
                creep.log('info',`找不到路径`,p)
            }
             
        }
        else
        {
            for(let k in creep.store)
            {
                creep.drop( k as ResourceConstant);
                break;
            }
            
        }
        
        return  EActionCode.RUNNING;
    }
}